package yunwo.cn.yzstation.adapter;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import yunwo.cn.yzstation.R;
import yunwo.cn.yzstation.bean.EndOrganbean;

/**
 * Created by linchubin on 2017/3/27.
 */

public class EndOrganAdapter extends BaseAdapter {
    private List<EndOrganbean.DataBean> list;
    private Activity activity;
    public EndOrganAdapter(List<EndOrganbean.DataBean> list, Activity activity){
        this.list = list;
        this.activity = activity;
    }
    @Override
    public int getCount() {
        return list == null ? 0 : list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHold hold;
        if (convertView != null) {
            hold = (ViewHold) convertView.getTag();
        } else {
            convertView = activity.getLayoutInflater().inflate(R.layout.half_screen_item_view, null);
            hold = new ViewHold();
            hold.textTV = (TextView) convertView.findViewById(R.id.textTV);
            convertView.setTag(hold);
        }
        String str = list.get(position).getEndOrganName();
        hold.textTV.setText(str);
        return convertView;
    }

    class ViewHold {
        public TextView textTV;
    }
}